package com.china08.yxyapi.service.tifenbao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.china08.yxyapi.entity.mg.huixue.YxyHuixuePlan;
import com.china08.yxyapi.repository.mg.huixue.YxyHuixuePlanRepository;
import com.china08.yxyapi.service.tifenbao.TifenbaoPlanUpdService;

@Service
public class TifenbaoPlanUpdServiceImpl implements TifenbaoPlanUpdService {
    @Autowired
    private YxyHuixuePlanRepository yxyHuixuePlanRepository;

    @Override
    @Transactional
    public Integer updatePlan(String id, Double score) {
        YxyHuixuePlan yxyHuixuePlan = yxyHuixuePlanRepository.findOne(id);
        yxyHuixuePlan.setCurrentScore(score);
        yxyHuixuePlanRepository.save(yxyHuixuePlan);
        YxyHuixuePlan yxyHuixuePlanupdate = yxyHuixuePlanRepository.findOne(id);
        if (yxyHuixuePlanupdate != null && yxyHuixuePlanupdate.getCurrentScore() != -1) {
            return 1;
        } else {
            return 0;
        }
    }

}
